package main

import "fmt"

// 有一个数组 [1,4,9,16,2,5,10,15]
// 生成一个新切片，要求新切片元素是数组相邻2项的和

func main() {
	a := [8]int{1, 4, 9, 16, 2, 5, 10, 15}
	s := make([]int, 4)
	cnt := 0
	for i := 0; i <= 6; i += 2 {
		s[cnt] = a[i] + a[i+1]
		cnt++
	}
	for i, v := range s {
		fmt.Printf("s[%d] = %d\n", i, v)
	}
}
